<template>
	<view>
		<view class="page-body">
			<view class="page-section page-section-gap">
				<!-- \:markers="covers" -->
				<map style="width: 100vw; height: 100vh;" :latitude="latitude" :longitude="longitude" :markers="markers" :polyline="polyline">
				</map>
			</view>
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				markers: [],
				polyline: [], 
				key: 'H7YBZ-X62CX-TB64J-7MIKJ-N7UNH-T4FWM',
				id: 0, // 使用 marker点击事件 需要填写id
				title: 'map',
				latitude: '',
				longitude: '',
				covers: [{
					latitude: '',
					longitude: '',
					iconPath: '/static/h1.png'
				}, {
					latitude: 39.90,
					longitude: 116.39,
					iconPath: '/static/h1.png'
				}]
			}
		},
		onLoad(options) {
			let that = this;
			if (options.latitude) {
				this.latitude = options.latitude;
				this.longitude = options.longitude
			} else {
				this.getuserLocation();
			}
			
		},
		methods: {

			getuserLocation() {
				let that = this;
				uni.getLocation({
					type: 'gcj02',
					success: function(res) {
						console.log(res)
						console.log(res.latitude)
						that.latitude = res.latitude;
						that.longitude = res.longitude
						that.covers[0].latitude = res.latitude
						that.covers[0].longitude = res.longitude
					}
				})
			}
		}
	}
</script>

<style>

</style>
